import { h } from 'preact';
import { observer } from 'mobx-react';

import CircleNode from './CircleNode';
import RectNode from './RectNode';
const componentMap = new Map();

setComponent('rect', RectNode);
setComponent('circle', CircleNode);

export function getComponent (type) {
  const component = componentMap.get(type);
  if (!component) {
    throw new Error('未注册的类型')
  }
  return component;
}

export function setComponent (type, component) {
  return componentMap.set(type, observer(component))
}
